package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import org.come.Jpanel.TakeBackPawnGoodsJpanel.fy;
import org.come.mouslisten.TakeBackGoodMouslisten;
import org.come.until.DDGoodUntil;
import org.come.until.FormsManagement;

import com.tool.btn.FormsOnOffBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;



public class TakeBackPawnGoodsJpanel1 extends JPanel implements MouseListener {

    private JLabel[] labgoods = new JLabel[42];// 用来放置典当的物品
    private FormsOnOffBtn orderflag;//整理当铺
    private TakeBackGoodMouslisten[] backGoodMouslistens = new TakeBackGoodMouslisten[42];

    // private JLabel labOne,//第一页按钮
    // labTwo;//第二页按钮

    private JLabel[] jabs = new JLabel[7];//典当增加8格

    public TakeBackPawnGoodsJpanel1() throws Exception {

        this.setPreferredSize(new Dimension(386, 440));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);
        //
        // JLabel label = new JLabel();
        // label.setIcon(CutButtonImage.cuts("inkImg/hongmu/2/8_jpg.button.btn_close.jpg")[0]);
        // label.setBounds(335, 0, 54, 15);
        // label.addMouseListener(this);
        // this.add(label);

        // 关闭按钮事件
        FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 55);
        offBtn.setBounds(386 - 37, 10, 25, 25);
        this.add(offBtn);

        // 用来放置典当的物品
        for (int i = 0; i < 42; i++) {

            int row = i % 6;
            int col = i / 6;

            labgoods[i] = new JLabel();
            labgoods[i].setBounds(50 + row * 51, 33 + col * 51, 50, 50);
            this.add(labgoods[i]);
            backGoodMouslistens[i] = new TakeBackGoodMouslisten(i);
            labgoods[i].addMouseListener(backGoodMouslistens[i]);
        }

        ImageIcon imageIcon = new ImageIcon("skin/8100226/button/B162.png");

        // 第一页按钮

        for (int i = 0; i < jabs.length; i++) {
            jabs[i] = new JLabel();
            jabs[i].setBounds(47 + 41 * i, 396, 39, 23);
            jabs[i].setIcon(imageIcon);
            jabs[i].setBackground(UIUtils.Color_BACK);
            jabs[i].setText((i + 1) + "");
            jabs[i].addMouseListener(new fy(i + 1));
            jabs[i].setHorizontalTextPosition(SwingConstants.CENTER);
            jabs[i].setFont(UIUtils.TEXT_FONT1);
            jabs[i].setForeground(Color.WHITE);
            this.add(jabs[i]);
        }
        this.orderflag = new FormsOnOffBtn("skin/8100226/button/19.png", 1, UIUtils.COLOR_BTNPUTONG, "整", 805);
        this.orderflag.setBounds(340, 398, 19, 19);
        this.add(this.orderflag);

    }

    class fy implements MouseListener {
        private int y;

        public fy(int y) {
            super();
            this.y = y;
        }
        @Override
        public void mouseClicked(MouseEvent e) {
            for(int i = 0; i < TakeBackPawnGoodsJpanel1.this.jabs.length; ++i) {
                if (this.y - 1 == i) {
                    TakeBackPawnGoodsJpanel1.this.jabs[i].setForeground(Color.YELLOW);
                    TakeBackPawnGoodsJpanel1.this.jabs[i].setFont(UIUtils.TEXT_FONT1B);
                } else {
                    TakeBackPawnGoodsJpanel1.this.jabs[i].setForeground(Color.WHITE);
                    TakeBackPawnGoodsJpanel1.this.jabs[i].setFont(UIUtils.TEXT_FONT1);
                }
            }
        }
        @Override
        public void mousePressed(MouseEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mouseReleased(MouseEvent e) {
            // TODO Auto-generated method stub
            DDGoodUntil.ys = y;
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void mouseExited(MouseEvent e) {
            // TODO Auto-generated method stub

        }

    }



    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        if (MyIsif.getStyle().equals("水墨UI")){
            super.paintComponent(g);
            // 技能
            if (icon == null) {
                icon = new ImageIcon("inkImg/newbackground/B308.png");
            }

            g.drawImage(icon.getImage(), 0, 0, 386, 440, this);
            DDGoodUntil.draw(g, 50, 33);
        }else {
            super.paintComponent(g);
            // 技能
            if (icon == null) {
                icon = new ImageIcon("skin/8100226/button/hongmu/典当取回红木.png");
            }

            g.drawImage(icon.getImage(), 0, 0, 386, 440, this);
            DDGoodUntil.draw(g, 50, 33);
        }
    }


    @Override
    public void mouseClicked(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseExited(MouseEvent e) {
        // TODO 自动生成的方法存根

    }

    @Override
    public void mousePressed(MouseEvent e) {
        // TODO 自动生成的方法存根

    }

    @Override
    public void mouseReleased(MouseEvent e) {
        // TODO 自动生成的方法存根

    }


    @Override
    public void mouseEntered(MouseEvent e) {
        // TODO 自动生成的方法存根

    }

}

        

